﻿using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using System.Collections;
using UnityEditor;

[CustomEditor(typeof(Resize))]
public class ResizeEditor : Editor
{
    // Use this for initialization
    void Start()
    {

    }

    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        if (((Resize)target).transform.localScale.x == 1 && ((Resize)target).transform.localScale.z == 1 && ((Resize)target).renderer != null)
        {
            Texture text = ((Resize)target).renderer.materials[0].mainTexture;

            if (text == null) return;

            Debug.Log(text.width + " " + text.height);
            ((Resize)target).transform.localScale = new Vector3((float)text.width / (float)100, 1, -(float)text.height / (float)100);
        }

    }
}
